bitkeeper revision 1.283 (3f094288pNoSBSaFk_QayYrITerstw)
authorrac61@labyrinth.cl.cam.ac.uk <rac61@labyrinth.cl.cam.ac.uk>
Mon, 7 Jul 2003 09:51:04 +0000 (09:51 +0000)
committerrac61@labyrinth.cl.cam.ac.uk <rac61@labyrinth.cl.cam.ac.uk>
Mon, 7 Jul 2003 09:51:04 +0000 (09:51 +0000)
Add support for imaginary/virtual/whatever you want to call them partition tables used by raw disks
Change diskno data type back, changing it was a silly idea.

tools/control/src/org/xenoserver/cmdline/ParsePhysicalGrant.java
tools/control/src/org/xenoserver/control/CommandPhysicalGrant.java
tools/control/src/org/xenoserver/control/CommandPhysicalRevoke.java
tools/control/src/org/xenoserver/control/Extent.java
tools/control/src/org/xenoserver/control/Partition.java

index 6792a43e4744c2f30bc43ecb9df67c86359edc39..ba8198327397ab3a991c967d6ca5459e3441a63c 100644 (file)
@@ -43,8 +43,9 @@ public class ParsePhysicalGrant extends CommandParser {
      
     // Convert the partition into a physical extent
     Extent e = p.toExtent();
+    int partition_no = p.getMinor() & 0x1F;
     
-    String output = new CommandPhysicalGrant( d, domain_id, e, mode ).execute();
+    String output = new CommandPhysicalGrant( d, domain_id, e, mode, partition_no ).execute();
     if ( output != null )
       System.out.println( output );
   }
index c7152e46c3bad20eb079f3f238bb71f9330e90fa..03323d75f642070f7ae7f147d562ecc1c17d4983 100644 (file)
@@ -5,6 +5,7 @@ public class CommandPhysicalGrant extends Command {
   private int domain_id;
   private Extent extent;
   private Mode mode;
+  private int partition_no;
 
   /**
    * Constructor for CommandPhysicalGrant.
@@ -12,16 +13,19 @@ public class CommandPhysicalGrant extends Command {
    * @param domain_id Domain to grant access for.
    * @param extent Extent to grant access to.
    * @param mode Access mode to grant.
+   * @param partition_no Partition number to use (or zero for none).
    */
   public CommandPhysicalGrant(
     Defaults d,
     int domain_id,
     Extent extent,
-    Mode mode) {
+    Mode mode,
+    int partition_no) {
     this.d = d;
     this.domain_id = domain_id;
     this.extent = extent;
     this.mode = mode;
+    this.partition_no = partition_no;
   }
 
   public String execute() throws CommandFailedException {
@@ -30,7 +34,7 @@ public class CommandPhysicalGrant extends Command {
 
     try {
       Process start_p;
-      String start_cmdarray[] = new String[6];
+      String start_cmdarray[] = new String[7];
       int start_rc;
       start_cmdarray[0] = d.XIToolsDir + "xi_phys_grant";
       if ( mode == Mode.READ_WRITE )
@@ -40,9 +44,10 @@ public class CommandPhysicalGrant extends Command {
       else
         throw new CommandFailedException( "Unknown access mode '" + mode + "'" );
       start_cmdarray[2] = Integer.toString( domain_id );
-      start_cmdarray[3] = Short.toString( extent.getDisk() );
+      start_cmdarray[3] = Integer.toString( extent.getDisk() );
       start_cmdarray[4] = Long.toString( extent.getOffset() );
       start_cmdarray[5] = Long.toString( extent.getSize() );
+      start_cmdarray[6] = Integer.toString( partition_no );
 
       if (Settings.TEST) {
         output = reportCommand(start_cmdarray);
index 63052b1d4bbc35a1c312133c236d63c0abbd443f..290af9ffe34f9cb7da3f18379506e6e17f1fe8a3 100644 (file)
@@ -30,7 +30,7 @@ public class CommandPhysicalRevoke extends Command {
       int start_rc;
       start_cmdarray[0] = d.XIToolsDir + "xi_phys_revoke";
       start_cmdarray[1] = Integer.toString( domain_id );
-      start_cmdarray[2] = Short.toString( extent.getDisk() );
+      start_cmdarray[2] = Integer.toString( extent.getDisk() );
       start_cmdarray[3] = Long.toString( extent.getOffset() );
       start_cmdarray[4] = Long.toString( extent.getSize() );
 
index e4ccff68062a16574fbd6ae9b9b06295b313afec..cd653a9ed9270ed24d67a6b4bd75a7924cdee13e 100644 (file)
@@ -8,11 +8,11 @@ package org.xenoserver.control;
 public class
 Extent
 {
-  short disk;
+  int disk;
   long offset;                                           /* offset into disk */
   long size;                      /* size of this extent in 512 byte sectors */
 
-  public short
+  public int
   getDisk()
   {
     return disk;
index 03237c5fb13c548e306b44f489057b80f9063710..5ca9e02b3e189638d89cde14157ddc837ea332b3 100644 (file)
@@ -161,11 +161,10 @@ Partition
   {
     Extent e = new Extent();
     // Build 16-bit disk number.. high 8 bits are the major
-    int disknum = major << 8;
+    e.disk = major << 8;
     // Low 8 bits are the minor, but bottom 5 need to be cleared
     // as they are the partition number, not the disk number
-    disknum |= ( minor & 0xE0 );
-    e.disk = (short) disknum;
+    e.disk |= ( minor & 0xE0 );
     e.offset = start_sect;
     e.size = nr_sects;
     return e;
@@ -179,7 +178,7 @@ Partition
   {
     if ( e.getMajor() != major )
       return false;
-    if ( e.getMinor() != (minor & 0xE0) )
+    if ( e.getMinor() != minor )
       return false;
     if ( e.offset != start_sect )
       return false;